<?php
class EWebUser extends CWebUser{
 
    protected $_model;
 
   protected function loadUser()
    {
        if ( $this->_model === null ) {
                $this->_model = User::model()->findByPk( $this->id );
        }
        return $this->_model;
    }
    
    function getLevel()
    {
        $user=$this->loadUser();
        if($user)
            return $user->levelUser_id;
        return 100;
    }
	
	function isAdmin(){
		$user=$this->loadUser();
        if($user){
			if($user->levelUser_id==1){
				return true;
			}
		}
		return false;
	}
	function isWakilKetua(){
		$user=$this->loadUser();
        if($user){
			if($user->levelUser_id==3 || $user->levelUser_id==1){
				return true;
			}
		}
		return false;
	}
	function isSekretaris(){
		$user=$this->loadUser();
        if($user){
			if($user->levelUser_id==4 || $user->levelUser_id==1){
				return true;
			}
		}
		return false;
	}
	function isKetua(){
		$user=$this->loadUser();
        if($user){
			if($user->levelUser_id==2 || $user->levelUser_id==1){
				return true;
			}
		}
		return false;
	}
	function isBendahara(){
		$user=$this->loadUser();
        if($user){
			if($user->levelUser_id==5 || $user->levelUser_id==1){
				return true;
			}
		}
		return false;
	}
	function isKetuaWakil(){
		$user=$this->loadUser();
        if($user){
			if($user->levelUser_id<=3){
				return true;
			}
		}
		return false;
	}
	function isBPH(){
		$user=$this->loadUser();
        if($user){
			if($user->levelUser_id<=5){
				return true;
			}
		}
		return false;
	}
}